package com.hdl.util;

import javax.servlet.http.Cookie;

public class CookieUtil {
    /**
     * 返回需要的cookie
     * @param cookies cookie数组
     * @param key 需要的cookie名
     * @return
     */
    public static Cookie getCookie(Cookie[] cookies, String key){
        if(cookies != null) {
            for (Cookie cookie : cookies) {
                if (key.equals(cookie.getName())) {//自动登陆
                    return cookie;
                }
            }
        }
        return null;
    }
}
